package com.huifer.wgx.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Collection;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * <p>Title : FunctionEntity </p>
 * <p>Description : </p>
 *
 * @author huifer
 * @date 2019-03-20
 */
@Entity
@Table(name = "t_function", schema = "at15", catalog = "")
public class FunctionEntity {

    private Long functionId;
    private String functionName;
    private Collection<PersonnelEntity> tPersonnelsByFunctionId;

    @Id
    @Column(name = "function_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getFunctionId() {
        return functionId;
    }

    public void setFunctionId(Long functionId) {
        this.functionId = functionId;
    }

    @Basic
    @Column(name = "function_name", nullable = false, length = 20)
    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        FunctionEntity that = (FunctionEntity) o;
        return Objects.equals(functionId, that.functionId) &&
                Objects.equals(functionName, that.functionName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(functionId, functionName);
    }

    @OneToMany(mappedBy = "tFunctionByFunctionId")
    @JsonIgnore
    public Collection<PersonnelEntity> gettPersonnelsByFunctionId() {
        return tPersonnelsByFunctionId;
    }

    public void settPersonnelsByFunctionId(
            Collection<PersonnelEntity> tPersonnelsByFunctionId) {
        this.tPersonnelsByFunctionId = tPersonnelsByFunctionId;
    }
}
